package cn.kami.dao.impl;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.util.ArrayList;
import java.util.List;

import cn.kami.dao.IManufacturerDAO;
import cn.kami.vo.Manufacturer;

public class ManufacturerDAOImpl implements IManufacturerDAO {
	private Connection conn = null;
	private PreparedStatement pstmt = null;
	public ManufacturerDAOImpl(Connection conn){
		this.conn = conn;
	}
	@Override
	public List<Manufacturer> findAll(String keyWord)
			throws Exception {
		// TODO Auto-generated method stub
		List<Manufacturer> all = new ArrayList<Manufacturer>();
		String sql = "SELECT manu_id,manu_name FROM manufacturer";
		this.pstmt = this.conn.prepareStatement(sql);
		ResultSet rs = this.pstmt.executeQuery();
		Manufacturer manu = null;
		while(rs.next()){
			manu = new Manufacturer();
			manu.setManuID(rs.getString(1));
			manu.setManuName(rs.getString(2));
			all.add(manu);
		}
		this.pstmt.close();
		return all;
	}

}
